package com.lujianfei.babymilkmemory.compose.dialog

import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState

@Composable
fun MyPopupMenu(
    menuItems: List<String>,
    onClickCallbacks: (String) -> Unit,
    showMenu: MutableState<Boolean>,
    onDismiss: () -> Unit
) {
    DropdownMenu(
        expanded = showMenu.value,
        onDismissRequest = { onDismiss() },
    ) {
        menuItems.forEach { item ->
            DropdownMenuItem(text = {
                Text(text = item)
            }, onClick = {
                onDismiss()
                onClickCallbacks.invoke(item)
            })
        }
    }
}